/**
 * iSight edit
 * 
 * Licensed for Servitius
 * 
 * 
 */
 
 
// CKEDITOR stílusbeállítás
CKEDITOR.config.contentsCss = 'css/servitius_style.css';

var editor;

function editArticle(parent){
    if(!parent){
        // Error handling if variable not set
        alert('Error: editArticle parent not set.');
        return false;
    } 
    
    // ezt ajax get-tel kel majd helyettesíteni!!!!!
    var editableText = $(parent).html();
    //megsemmisítjük a már létező texteditorokat
    if ( editor )
        editor.destroy();
    // rátöltjük a ckeditort a textareankra
    editor = CKEDITOR.replace( 'editor_textarea', { 
        filebrowserBrowseUrl : location.href+'/ckeditor/ckfinder/ckfinder.html',
        filebrowserImageBrowseUrl : location.href+'/ckeditor/ckfinder/ckfinder.html?Type=Images',
        filebrowserFlashBrowseUrl : location.href+'/ckeditor/ckfinder/ckfinder.html?Type=Flash',
        filebrowserUploadUrl : location.href+'/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
        filebrowserImageUploadUrl : location.href+'/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
        filebrowserFlashUploadUrl : location.href+'/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash',
        language: 'hu'
    } );
    // betöltjük a megszerzett szerkesztendő szöveget a ckeditorba
    CKEDITOR.instances.editor_textarea.setData(editableText);
    
    $("#admin_editor").dialog({
        title: 'Szerkesztés - ' + parent,
        height: $(parent).height()+20,
        width: $(parent).width()+20,
        modal: true
    });
    return true;
}


$(document).ready(function() {
    /**
     * ez a rész kell ha mousover lesz és szerkesztés
     */

    console.log("admin js loaded");
   
    $("#servitius_content-edit").hide();
    $('#servitius_content').hover(function(){
        $(this).addClass("divHover")
        $("#servitius_content-edit").show("fast")
    }, function(){
        $(this).removeClass("divHover");
        $("#servitius_content-edit").hide("fast")
    });
    
    $("#edit-div-number").button().click(function(){
        console.log("Hello world");
        $("#dialog-form").dialog( "open" );
    });

});


